<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
		<input type="text" name="text" id="text" value="" />
    
</body>
</html>
<script>
    // 匹配一个手机号  
    //		function checkPhone(){ 
        var phone = document.getElementById('text');
    //		    if(!(/^1[3456789]\d{9}$/.test(phone))){ 
    //		        alert("手机号码有误，请重填");  
    //		        return false; 
    //		    } 
                
                phone.onblur = function(){
                    if(!(/^1[3456789]\d{9}$/.test(phone.value))){ 
                        alert("手机号码有误，请重填");  
                        phone.value=''
                        return false; 
                    } else{
                        alert('成功登陆')
                    }
                }
    //		}



    //手机号码  
    var pattern = /0?(13|14|15|18|17)[0-9]{9}/;
    var right = '13265456162';
    var err = '11123224332';
    console.log(pattern.test(right));   //true
    console.log(pattern.test(err));     //false

    //邮箱 
    var pattern = /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/;
    var rightEmail = '112@qq.com';
    var errEmail = '112@dcom';
    console.log(pattern.test(rightEmail));   //true
    console.log(pattern.test(errEmail));     //false

    //身份证 
    var pattern = /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/;
    var right = '110101199003078398';
    var err = '4452211991123265554';
    console.log(pattern.test(right));   //true
    console.log(pattern.test(err));     //false
 
    //SmallDemo
     
    

</script>